<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of js
 *
 * @author clive
 */
class js {

    //put your code here

    public static function sysalert($str) {
        echo '<title>错误报告</title>';
        echo '<meta http-equiv="Content-Type" content="text/html; charset=utf-8">';
        echo $str;
        echo '<br /><a href="?">返回注册页面</a>';
        exit;
    }

    public static function alertinfo($str, $url) {
        echo '<script>';
        echo 'alert("' . addslashes($str) . '");';
        if ($url != '')
            echo 'location.href="' . $url . '";';
        echo '</script>';
    }

    public static function alert($str, $url = '') {
        register_shutdown_function(array(__CLASS__, 'alertinfo'), $str, $url);
    }

    public static function error($str, $url = '?') {
        echo '<script>';
        echo 'alert("' . addslashes($str) . '");';
        echo 'location.href="' . $url . '";';
        echo '</script>';
        exit;
    }

    public static function confirminfo($str, $url1, $url2) {
        echo '<script>';
        $str = addslashes($str);
        $str = str_replace("\r\n", "\\r\\n", $str);
        echo 'if(confirm("' . $str . '")){';
        if ($url1 > '')
            echo 'location.href="' . $url1 . '";';
        echo '}else{';
        if ($url2 > '')
            echo 'location.href="' . $url2 . '";';
        echo '}';
        echo '</script>';
    }

    public static function confirm($str, $url1, $url2) {
        //第三个参数$a为1的时候点[确定]执行跳转,为2的时候点[取消]才执行
        register_shutdown_function(array(__CLASS__, 'confirminfo'), $str, $url1, $url2);
    }

    public static function reloadinfo($url) {
        echo '<script>';
        echo 'location.href="' . $url . '";';
        echo '</script>';
    }

    public static function reload($url = '?') {
        register_shutdown_function(array(__CLASS__, 'reloadinfo'), $url);
    }

}
